package com.chandra.pos.employee.web;


import com.chandra.pos.common.web.POSController;
import com.chandra.pos.employee.model.EmployeeModel;
import com.chandra.pos.employee.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/* @(#) AdminController.java
 * Copyright 2013 - 2015 QatarAirways Group. All Rights Reserved.
 *
 * This Software is the proprietary information of QR Group
 * Use is subject to License terms.
 * Created by T4671 on 06/04/2015.
 */
@Controller
@RequestMapping("admin")
public class AdminController extends POSController {

    private static String PAGE_MODULE = "admin";

    protected static String PAGE_PROFILE = "profile";

    protected static String PAGE_SETTINGS = "settings";


    @Autowired
    protected EmployeeService employeeService;


    public AdminController() {
        this.setTabIndex(1);

    }


    @RequestMapping(value = {"", "/"}, method = RequestMethod.GET)
    public String index(EmployeeModel model) {

        return getPageURL(PAGE_MODULE, PAGE_HOME);

    }

    @RequestMapping(value = "/home", method = RequestMethod.GET)
    public String home(EmployeeModel model) {

        return getPageView(PAGE_MODULE, PAGE_HOME);

    }

    @RequestMapping(value = "/profile", method = RequestMethod.GET)
    public String profile(EmployeeModel model) {

        return getPageView(PAGE_MODULE, PAGE_PROFILE);

    }

    @RequestMapping(value = "/settings", method = RequestMethod.GET)
    public String settings(EmployeeModel model) {
        UserDetails userDetails=getLoggedInUser();

        EmployeeModel employeeModel= employeeService.getByUserName(userDetails.getUsername());


        return getPageView(PAGE_MODULE, PAGE_SETTINGS);

    }
}
